import random  
import string  
  
def generate_password():  
    # 确定密码长度  
    length = random.randint(12, 16)  
      
    # 确定密码的字符集，包括大小写字母、数字和特殊字符  
    characters = string.ascii_letters + string.digits + string.punctuation  
      
    # 生成密码  
    password = ''.join(random.choice(characters) for i in range(length))  
      
    return password  
  
# 生成并打印密码  
password = generate_password()  
print(password)